import type { MenuProps } from 'antd';
import { useNavigate } from 'react-router-dom';

function useMenuStore() {

    const navigate = useNavigate()

    const items1: MenuProps['items'] = ['1', '2', '3'].map((key) => ({
        key,
        label: `nav ${key}`,
    }));


    const items2: MenuProps['items'] = [
        {
            key: 'listPage',
            label: '列表页',
            children: [
                {
                    key: 'cardlist',
                    label: '卡片列表',
                    onClick: () => handleClick('/layout/cardlist')
                },
                {
                    key: 'querylist',
                    label: '查询列表',
                    onClick: () => handleClick('/layout/querylist')
                },
            ]
        },
        {
            key: 'userPage',
            label: '用户管理',
            children: [
                {
                    key: 'rolelist',
                    label: '权限列表',
                    onClick: () => handleClick('/layout/roleList')
                },
                {
                    key: 'userlist',
                    label: '用户列表',
                    onClick: () => handleClick('/layout/userlist')
                },
                {
                    key: 'departmentlist',
                    label: '部门列表',
                    onClick: () => handleClick('/layout/departmentlist')
                },
            ]
        },
        {
            key: 'logsManagePage',
            label: '日志管理',
            children: [
                {
                    key: 'loginlogs',
                    label: '登录日志',
                    onClick: () => handleClick('/layout/loginlogs')
                }
            ]
        },
        {
            key: 'iconspage',
            label: '图标库',
            onClick: () => handleClick('/layout/loginlogs')
        },
        {
            key: 'viewsmanage',
            label: '页面管理',
            onClick: () => handleClick('/layout/viewsmanage')
        },

    ]

    const handleClick = (path: string) => {
        navigate(path)
    }

    return (
        {
            headMenu: items1,
            sideMenus: items2,
            handleClick
        }
    )
}

export default useMenuStore;